import request from '@/utils/request.js'

export const getArticles = (params) => {
  return request({
    method: 'GET',
    url: '/mp/v1_0/articles',
    params: params
  })
}

export const getArticleChannels = () => {
  return request({
    method: 'GET',
    url: '/mp/v1_0/channels'
  })
}

export const deleteArticle = (articleId) => {
  return request({
    method: 'DELETE',
    url: '/mp/v1_0/articles/' + articleId
  })
}

export const publishArticle = (body, draft) => {
  return request({
    method: 'POST',
    url: '/mp/v1_0/articles',
    params: { draft: draft },
    data: body
  })
}

export const getArticle = (articleId) => {
  return request({
    method: 'GET',
    url: '/mp/v1_0/articles/' + articleId
  })
}

export const updateArticle = (articleId, body, draft) => {
  return request({
    method: 'PUT',
    url: '/mp/v1_0/articles/' + articleId,
    params: { draft: draft },
    data: body
  })
}

export const updateCommentStatus = (articleId, allowComment) => {
  return request({
    method: 'PUT',
    url: '/mp/v1_0/comments/status',
    params: { article_id: articleId },
    data: { allow_comment: allowComment }
  })
}
